{extend name="base"}
{block name="main"}

<style type="text/css">
.table td,.table th{
  text-align: center;
}
.table .left{
  text-align: left;
}
.table .right{
  text-align: right;
}
.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th{
    background: none;
}
.ismoblie .row{
	margin: 0px;
	border: 1px solid #CCC;
	border-bottom: none;
	border-right: none;
	text-align: center;
	margin-bottom: 20px;
}
.ismoblie .row div[class^="col-xs"]{
	border: 1px solid #CCC;
	border-top: none;
	border-left: none;
	line-height: 30px;
	height: 30px;
}
.ismoblie .row .subtitle{
	background-color: #EEEE;
}
</style>

{js href="__JQUERY__/clipboard.min.js" /}
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">产品订单历史明细</header>
            <div class="panel-body">				
				<div class="col-md-12 col-xs-12">
					<div class="col-md-2 col-xs-12">
					<a href="{:U('Deal/index')}"><button type="button" class="btn btn-info"><i class="icon-reply"></i> 订单管理中心</button></a>
					</div>
				    <form method="get" name="search" action="{:U('Deal/clothbuy')}">
					<div class="col-md-3 col-xs-12">
						<div class="input-group m-bot15">
							<span class="input-group-addon">编号</span>
							<input name="number" type="text" class="form-control" placeholder="请输入面料编号" autocomplete="off" value="{$number}">
						</div>
					</div>
					<div class="col-md-3 col-xs-12">
						<div class="input-group m-bot15">
							<span class="input-group-addon">色号</span>
							<input name="color" type="text" class="form-control" placeholder="请输入编号下的色号" autocomplete="off" value="{$color}">
						</div>
					</div>
					
				    <div class="col-md-2 col-xs-12">
				        <button type="submit" class="btn btn-primary"><i class="icon-search"></i> 搜索</button>
				    </div>
				    </form>
				</div>
            </div>
        </section>
    </div>
</div>
<div class="row">
	{if isMobile()}
		<!--手机端显示-->
		<div class="col-xs-12 ismoblie" mobileshow>
			<section class="panel" style="padding: 8px;">
				{volist name="T.data" id="v"}
				{php}
				if($knum==''){
					$knum=$v['dealid'];
					$bgcolor='f8fbff';
				}
				if($v['dealid']!=$knum){
					$knum=$v['dealid'];
					$bgcolor=$bgcolor=='f8fbff' ? 'fffffb' : 'f8fbff';
				}
				{/php}
				<div class="row" style="background-color:#{$bgcolor} ;">
					<div class="col-xs-6 subtitle">
						<a href="{:U('Deal/printing',array('id'=>$v['did'],'number'=>$v['dealid']))}">
						单号：{$v.dealid|substr="-6"}
						</a>
					</div>
					<div class="col-xs-4" style="text-align: right;">
						{$v.create_time|date="Y/m/d"}
					</div>
					<div class="col-xs-2" style="background-color: #{$v.colorval};">
						
					</div>
					<div class="col-xs-8" style="text-align: left;">
						{$v.number} # {$v.name}
					</div>
					<div class="col-xs-4">
						{$v.color} # {$v.colorname}
					</div>
					{php}
					  $w=unserialize($v['weight']);
					  foreach($w as $val){
						echo '<div class="col-xs-3">'.$val.'</div>';
					  }
					{/php}
					<div class="col-xs-4">{$v.unitprice|price_one} 元</div>
					<div class="col-xs-4">{$v.total|price} 元</div>
					<div class="col-xs-4">{$v['courier']}</div>	
				</div>
				{/volist}
				<div class="col-xs-12">{$T.mshow|raw}</div>
			</section>
		</div>
	{else}
	
    <!--PC端显示-->
    <div class="col-lg-12" pcshow>
        <section class="panel">
            <table class="table table-bordered table-striped table-condensed">
                <thead>
					<tr>
						<td width="6%">下单时间</td>		
						<td width="5%">客户</td>
						<td width="4%">编号</td>
						<td width="12%">品名</td>
						<td width="4%">色号</td>
						<td width="5%">颜色</td>
						<td width="2%"></td>
						<td width="3%">1</td>
						<td width="3%">2</td>
						<td width="3%">3</td>
						<td width="3%">4</td>
						<td width="3%">5</td>
						<td width="3%">6</td>
						<td width="3%">7</td>
						<td width="3%">8</td>
						<td width="5%">数量</td>
						<td width="5%">单价</td>
						<td width="5%">金额</td>
						<td width="7%">批次 / 缸号</td>
						<td width="6%">物流</td>
						<td width="10%">操作</td>
					</tr>
				</thead>
				<tbody>
                {volist name="T.data" id="v"}
                {php}
				if($knum==''){
					$knum=$v['dealid'];
					$bgcolor='f8fbff';
				}
				if($v['dealid']!=$knum){
					$knum=$v['dealid'];
					$bgcolor=$bgcolor=='f8fbff' ? 'fffffb' : 'f8fbff';
				}
				echo "<tr style='background: #".$bgcolor."'>";
                {/php}
                <td align="center"><a href="{:U('Deal/info',array('id'=>$v['did'],'number'=>$v['dealid']))}" title="明细" target="_blank">{$v.create_time|date="Y/m/d"}</a></td>
                <!--<td align="center">{$v.dealid|substr="-6"}</td> -->
                <td><a copy="{$v.cusname},{$v.phone|base64_decode},{$v.address}">{$v.cusname}</a></td>
                <td>{$v.number}</td>
                <td style="text-align:left">&nbsp;&nbsp;{$v.name}</td>
                <td {if ($v.number!=$v.libnumber && $v.colorname!='')} style="color: #CC0000;" {/if}>{$v.color} #</td>
				<td>{$v.colorname}</td>
				<td style="background-color: #{$v.colorval};"></td>
                {php}
                  $w=unserialize($v['weight']);
                  foreach($w as $val){
					echo '<td>'.$val.'</td>';
                  }
                {/php}
                <td>{$v.count} {$v.unit}</td>
                <td>{$v.unitprice|price_one}</td>
                <td class="right">{$v.total|price}</td>
                <td>{$v.bacth}</td>
                <td>
					<a href="https://www.kuaidi100.com/chaxun?com={$courier[$v['courier']]['key']|default=''}&nu={$v.kdnumber}" target="_blank">{$v['courier']}</a>
                </td>
                <td>
					<a href="{:U('Deal/update',array('id'=>$v['did'],'number'=>$v['dealid']))}" title="编辑" target="_blank"><i class="icon-pencil"></i> 编辑</a>&nbsp;
					<a href="{:U('Deal/printing',array('id'=>$v['did'],'number'=>$v['dealid']))}" target="_blank" title="打印"><i class="icon-print"></i> 打印</a>
                </td>
                </tr>
                {/volist}
                <td colspan="21" >{$T.show|raw}</td>
                </tbody>
            </table>
        </section>
    </div>
	
	{/if}
</div>

<script type="text/javascript">
$('#hbprit').click(function(){
    var url="{:U('Deal/printing',array('mid'=>'iddata'))}";
    var did=$("input[type=checkbox]:checked");
    var data='';
    var cuid='';
    var statu=true;
    if(did.length>1){
        did.each(function(){
            data+=$(this).val()+'|';
            if(cuid==''){
                cuid=$(this).attr('id-data');
            }else{
                if(cuid!=$(this).attr('id-data')){
					statu=false;
					return false;
                }
            }
        });
        if(statu){
            data=data.substr(0,data.length-1);
            url=url.replace('iddata',data);
            window.open(url);
        }else{
            Alert('合并打印必须是同个客户','info');
        }
    }else{
        Alert('请至少勾选两个订单！','info',3);
    }
});
$('[copy]').click(function(){
    var txt=$(this).attr('copy');
    var clipboard = new ClipboardJS('[copy]', {
        text: function() {
            return txt;
        }
    });
   clipboard.on('success', function(e) {
        Alert('复制成功！',"success",1);
        });
   clipboard.on('error', function(e) {
        Alert('复制失败！',"error",3);
    });
})
</script>
{/block} 
  